package com.baiyue.utils;

import com.baiyue.entity.UserEntity;

/**
 * @author 伍波
 * @date 2023/6/5 17:58
 */
public class UserHolderUtil {
    private static final ThreadLocal<UserEntity> USER_HOLDER = new ThreadLocal<>(); // 使用 ThreadLocal 存储用户信息

    public static void setUser(UserEntity user) {
        USER_HOLDER.set(user);
    }

    public static UserEntity getUser() {
        return USER_HOLDER.get();
    }

    public static void clear() {
        USER_HOLDER.remove();
    }
}
